<?php

namespace Home\Model;

use Think\Model;

/**
 * 分类模型
 */
class AdModel extends Model
{

    protected function _initialize()
    {
        $this->prefix = C('DB_PREFIX');
    }

    /**
     * [getAdPositionList 获取广告指定位置列表]
     * @param  [type] $position [description]
     * @return [type]           [description]
     */
    public function getListByPositionName($name)
    {
        $where = array();
        $where['ap.status'] = $where['a.status'] = 1;
        $where['ap.name'] = $name;
        $result  =   M()->field("a.*")
            ->table($this->prefix."ad_position ap")
            ->join($this->prefix."ad a ON ap.id=a.position_id")
            ->where($where)
            ->order('sort asc, a.id desc')
            ->select();
        return $result;
    }

}
